<?php
class PNBrandArray extends PNObjectExArray {
  function PNBrandArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'icarrent_brand';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';

    $this->_init($init, $where);
  }

  function genSort(){
    return "ORDER BY bra_name";
  }

  function selectExtendResult(){
 
    $this->_objData;
    $result = array();
    $joinInfo[]     = array ( 'join_table'  =>  'icarrent_category',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('category_name'),
                            'compare_field_table' =>  'category_id',
                            'compare_field_join'  =>  'id');

    $joinInfo[]     = array ( 'join_table'  =>  'icarrent_subcategory',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('subcategory_name'),
                            'compare_field_table' =>  'subcategory_id',
                            'compare_field_join'  =>  'id');

    foreach($this->_objData as $key=>$item){
        $result['subcategory_brand'][] = DBUtil::selectExpandedObjectArray('icarrent_subcategory_brand', $joinInfo, "sbra_brand_id = ".$item[id], 'category_name, subcategory_name');
    }
    return $result;
  }
}